package com.alks.function.controller.system;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.sys.SysConfLang;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.vo.sys.LangTypeVO;
import com.alks.function.data.request.sys.ConfigLangRequest;
import com.alks.function.data.vo.stock.PageDataVO;
import com.alks.function.service.system.ISysConfLangService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: chen
 * @date: 2024/12/25
 * @description: 多语言配置
 */
@Slf4j
@RestController
@AllArgsConstructor
@ApiRestController("/sys/conf/lang")
@Api(value = "多语言配置", tags = "多语言配置")
public class SysConfigLangController {

    final private ISysConfLangService sysConfLangService;

    @WebLogger
    @GetMapping("/type")
    @ApiOperation(value = "查询分类列表", tags = "多语言配置")
    public ResponseInfo<List<LangTypeVO>> langType() {
        return ResponseInfo.ok(sysConfLangService.configType());
    }

    @WebLogger
    @PostMapping("/page")
    @ApiOperation(value = "分页查询", tags = "多语言配置")
    public ResponseInfo<PageDataVO<SysConfLang>> termPage(@RequestBody ConfigLangRequest request) {
        return ResponseInfo.ok(sysConfLangService.termPage(request));
    }

    @WebLogger
    @PostMapping("/save")
    @ApiOperation(value = "保存配置", tags = "多语言配置")
    public ResponseInfo<Boolean> saveConfig(@RequestBody SysConfLang sysConfLang) {
        return ResponseInfo.ok(sysConfLangService.saveConfig(sysConfLang));
    }

    @WebLogger
    @PostMapping("/delete")
    @ApiOperation(value = "删除配置", tags = "多语言配置")
    public ResponseInfo<Boolean> deleteConfig(@RequestParam List<Long> ids) {
        return ResponseInfo.ok(sysConfLangService.deleteConfig(ids));
    }
}
